package com.bjpowernode.seckillweb.service.impl;

import com.bjpowernode.constant.Constants;
import com.bjpowernode.entity.Orders;
import com.bjpowernode.seckillweb.service.OrderService;
import jakarta.annotation.Resource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * 订单service
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Resource
    private RedisTemplate redisTemplate;


    /**
     * 查询用户秒杀结果
     */
    @Override
    public Orders queryResult(Integer userId, Integer goodsId) {

        //之前在service的消费者中已经将订单信息放入redis中
        Orders orders = (Orders)redisTemplate.opsForValue().get(Constants.REDIS_RESULT +goodsId +  ":" + userId);

        return orders;
    }
}
